﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InstancingColor : MonoBehaviour
{
    [SerializeField]
    private Color color = Color.white;

    private static int colorID = Shader.PropertyToID("_Color");

    private void Awake()
    {
        OnValidate();
    }

    private void OnValidate()
    {
        var propertyBlock = new MaterialPropertyBlock();
        propertyBlock.SetColor(colorID,color);
        GetComponent<MeshRenderer>().SetPropertyBlock(propertyBlock);
    }
}
